package com.hospital.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.hospital.Entity.Card;
import com.hospital.activity.R;

import java.util.List;

/**
 * Created by wangjun on 2015/6/11.
 */
public class CardAdapter extends BaseAdapter {


    private Context mContext;
    private List<Card> mCards;
    public CardAdapter(Context mContext,List<Card> mCards)
    {
        this.mContext=mContext;
        this.mCards=mCards;
    }
    @Override
    public int getCount()
    {
        return mCards.size();
    }

    @Override
    public Object getItem(int Index)
    {
        return mCards.get(Index);
    }

    @Override
    public long getItemId(int Index)
    {
        return Index;
    }

    @Override
    public View getView(int Index, View mView, ViewGroup mParent)
    {
        mView= LayoutInflater.from(mContext).inflate(R.layout.layout_item, null);
        ImageView News_Pic=(ImageView)mView.findViewById(R.id.News_Pic);
        News_Pic.setImageResource(mCards.get(Index).getDrawable());
        TextView News_Title=(TextView)mView.findViewById(R.id.News_Title);
        News_Title.setText(mCards.get(Index).getDescription());
        //消息一
        ImageView News_Pic1=(ImageView)mView.findViewById(R.id.News_Pic1);
        News_Pic1.setImageResource(mCards.get(Index).getSubCards().get(0).getDrawable());
        TextView News_Title1=(TextView)mView.findViewById(R.id.News_Title1);
        News_Title1.setText(mCards.get(Index).getSubCards().get(0).getDescription());
        //消息二
        ImageView News_Pic2=(ImageView)mView.findViewById(R.id.News_Pic2);
        News_Pic2.setImageResource(mCards.get(Index).getSubCards().get(1).getDrawable());
        TextView News_Title2=(TextView)mView.findViewById(R.id.News_Title2);
        News_Title2.setText(mCards.get(Index).getSubCards().get(1).getDescription());
        //消息三
        ImageView News_Pic3=(ImageView)mView.findViewById(R.id.News_Pic3);
        News_Pic3.setImageResource(mCards.get(Index).getSubCards().get(2).getDrawable());
        TextView News_Title3=(TextView)mView.findViewById(R.id.News_Title3);
        News_Title3.setText(mCards.get(Index).getSubCards().get(2).getDescription());
        return mView;
    }
}
